/*    */ package cc.s2m.web.s2mBlog.controller.admin;
/*    */ 
/*    */ import cc.s2m.web.s2mBlog.controller.base.BaseController;
/*    */ import cc.s2m.web.s2mBlog.pojo.Admin;
/*    */ import cc.s2m.web.s2mBlog.service.IAdmin;
/*    */ import cc.s2m.web.s2mBlog.util.MemcacheKeys;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.commons.codec.digest.DigestUtils;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ import org.springframework.web.bind.annotation.RequestParam;
/*    */ import org.springframework.web.bind.annotation.ResponseBody;
/*    */ 
/*    */ @Controller("admin_PassWord")
/*    */ @RequestMapping({"/admin"})
/*    */ public class PassWord extends BaseController
/*    */ {
/*    */ 
/*    */   @Autowired
/*    */   private IAdmin adminService;
/*    */ 
/*    */   @RequestMapping(value={"/editPwd"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public String editPwd()
/*    */   {
/* 28 */     return "admin/editPass";
/*    */   }
/*    */ 
/*    */   @RequestMapping(value={"/editPwd/save"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   @ResponseBody
/*    */   public String save(HttpServletRequest request, HttpServletResponse response, @RequestParam(required=false) String oldPwd, @RequestParam(required=false) String password)
/*    */   {
/* 37 */     if ((oldPwd == null) || (oldPwd.trim().isEmpty())) {
/* 38 */       return "noOldPwd";
/*    */     }
/* 40 */     if ((password == null) || (password.trim().isEmpty())) {
/* 41 */       return "noPassword";
/*    */     }
/* 43 */     Admin admin = (Admin)getMemObjectFromCookie(MemcacheKeys.ADMIN_SESSION, request);
/* 44 */     if (!admin.getPwd().equals(DigestUtils.md5Hex(oldPwd))) {
/* 45 */       return "errorPassword";
/*    */     }
/* 47 */     admin.setPwd(DigestUtils.md5Hex(password));
/* 48 */     this.adminService.updateByPrimaryKey(admin);
/*    */ 
/* 50 */     delMemObjectFromCookie(MemcacheKeys.ADMIN_SESSION, request, response);
/*    */ 
/* 52 */     return "success";
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\s2mBlog.zip
 * Qualified Name:     s2mBlog-3.0.0.WEB-INF.classes.cc.s2m.web.s2mBlog.controller.admin.PassWord
 * JD-Core Version:    0.6.1
 */